<template>
  <div id="test">
    <el-upload
      :multiple="multiple"
      action="auto"
      list-type="picture-card"
      :auto-upload="false"
      :http-request="uploadFile"
      ref="upload"
    >
      <i class="el-icon-plus"></i>
    </el-upload>
    <el-button @click="subPicForm">提交上传</el-button>
    {{ testData }}
  </div>
</template>
<script>
export default {
  name: 'test',
  data () {
    return {
      multiple: true,
      formDate: '',
      testData: ''
    }
  },
  methods: {
    uploadFile (file) {
      this.formDate.append('file', file.file)
    },
    subPicForm () {
      this.formDate = new FormData()
      this.$refs.upload.submit()
      this.formDate.append('phone', '12133')
      let config = {
        headers: {
          'Content-Type': 'multipart/form-data'
        }
      }
      this.axios.post('/api/upload', this.formDate, config).then(res => {
        console.log(res)
      }).catch(res => {
        console.log(res)
      })
    }

  },
  created () {
    // setTimeout(() => {
    // }, 1000)
    // 获取推荐页面卡片内容数据
    this.axios.get('/api/findNearLetter', {
      params: {
        phone: 13850045251
      }
    })
      .then((response) => {
        this.testData = response
        console.log(response)
      })
      .catch((error) => {
        this.$Notice.error({
          title: '通知',
          desc: '接口，异常！'
        })
        console.info(error)
      })
  }
}
</script>
